Skip to content

test: enable WebGPU rendering in headless Chromium - #81

Merged
jspanchu merged 11 commits into
masterfrom
fix-webgpu-tests
Jul 18, 2026
Merged

jspanchu merged 11 commits into
masterfrom
fix-webgpu-tests

Conversation

@jspanchu

Copy link
Copy Markdown
Member

No description provided.

Comment thread tests/conftest.py Outdated
@jourdain

Copy link
Copy Markdown
Collaborator

Also that does not warrant a release... rename your commit to test(webgpu): fix browser setup for WebGPU

jspanchu added 2 commits July 15, 2026 11:48
- Replace PIL/pixelmatch screenshot comparison in conftest with
vtkmodules.test.Testing.compareImageWithSavedImage. Diff and valid
images are written to the result directory via VTK_TEMP_DIR.

- Keep only the CI-generated baselines: promote *_github.png to the
primary baseline name and *_github_gpu.png to the VTK alternate
baseline convention (name_1.png), which RegressionTest tries
automatically. Drop the locally generated variants.

- Also launch Chromium with platform-specific ANGLE flags for webgpu
configs so a real WebGPU adapter is available.
Use uv run instead of sourcing the venv activate script, which lives
under Scripts/ instead of bin/ on Windows.
@jspanchu

Copy link
Copy Markdown
Member Author

linux, macos pass with vtkTesting.

windows fails because no osmesa is installed. let's install it.

@jspanchu

Copy link
Copy Markdown
Member Author

i found a f3d action that we can use https://github.com/f3d-app/install-mesa-windows-action/

GitHub windows runners have no GPU-accelerated OpenGL, so
vtkWin32OpenGLRenderWindow fails to get a pixel format and VTK falls
back to vtkOSOpenGLRenderWindow, which crashes when LoadLibrary cannot
find osmesa.dll. Download mesa-dist-win 25.0.7 (last release shipping
osmesa.dll) and put its x64 directory on PATH.
@jspanchu jspanchu changed the title fix(tests): enable WebGPU rendering in headless Chromium WIP fix(tests): enable WebGPU rendering in headless Chromium Jul 15, 2026
@jspanchu

jspanchu commented Jul 15, 2026 •

Copy link
Copy Markdown
Member Author

on windows, we will need to tweak flags to chromium so that it can use webgpu. i will investigate this some time later.

@jourdain

Copy link
Copy Markdown
Collaborator

It looks like the mac testing has some screenshot timing issue for volume rendering. I'm wondering what we can do to make those test more robust.

jspanchu added 4 commits July 17, 2026 16:21
vtkTesting derives the .diff/.valid output names by splitting the baseline
path on "/" only, so a Windows backslash path made it append the whole
absolute path to the temp results dir and fail to write the difference
image. Pass the baseline as a posix-style path.
On Windows, Dawn's D3D12 backend fails to create a device because the
bundled Chromium ships a dxil.dll it cannot load in the sandboxed GPU
process (EnsureDXCLibraries -> "DynamicLib.Open: dxil.dll Windows Error:
87"). The adapter is obtained fine; only requestDevice fails. Disabling
the use_dxc Dawn feature falls back to the FXC shader compiler, which
needs no external DLL. macOS (metal) and Linux (vulkan) do not use DXC,
so the flag is applied only on win32.
Pin the cone view to a fixed ref ("cone_view") so the test can address it
regardless of the process-global _vtklocalview_N counter, and assert the
active render window class (webgl vs webgpu) against it.

Run that assertion after every screenshot: getVtkObject() performs a
client-side serialize that currently corrupts the WebGPU render window
permanently (a VTK bug; harmless on webgl), which would blank all later
frames if done mid-sequence. The className comes from static server state,
so ordering it last does not weaken the check.
Fixed asyncio.sleep(0.1) waits were both flaky and masking a real bug: on
(re)mount the canvas starts at its 300x150 HTML default and only reaches
the container size after the 100ms debounced ResizeObserver calls
setSizeAsync, which does not bump the `updated` counter. A short sleep
could capture the wrong-sized frame. WebGPU also presents the updated
frame a frame later than the `updated` event, so an immediate capture
grabs a blank pre-present buffer.

Add Utils.wait_for_render, which polls on requestAnimationFrame until
every canvas drawing buffer matches its layout size (the same
floor(size * dpr + 0.5) formula the component uses) and stays stable for
two frames, giving the compositor time to present. Use it in the cone,
volume, and multi-view tests in place of every sleep.
@jspanchu

Copy link
Copy Markdown
Member Author

It looks like the mac testing has some screenshot timing issue for volume rendering. I'm wondering what we can do to make those test more robust.

this PR adds utils.wait_for_render that uses requestAnimationFrame + waits for canvas size to settle. It avoids sleeping for a magic interval and is deterministic.

tests pass locally in windows, we need to still figure out appropriate flags for GHA windows runners lacking a GPU

@jspanchu

Copy link
Copy Markdown
Member Author

Ah, pyproject.toml is using vtk 9.6.2 which does not support webgpu correctly. 9.7 wheels not out yet, so we need to use developer release.

jspanchu added 2 commits July 17, 2026 16:57
VTK does not support volume rendering on the WebGPU backend
Add vtk 9.7.20260712.dev0 to the dev group, tests need it to pass.

That dev wheel is published for Windows only as cp313/cp314 (no cp310
win_amd64), so bump the pytest matrix to Python 3.13 and pin uv to the
matrix interpreter via UV_PYTHON, which the workflow previously left to
uv's default.
@jspanchu

jspanchu commented Jul 17, 2026 •

Copy link
Copy Markdown
Member Author

we cannot run webgpu tests for linux/windows because ubunut-latest and windows-latest lack real GPUs. This PR atleast gets them to run locally.

@jspanchu jspanchu changed the title WIP fix(tests): enable WebGPU rendering in headless Chromium fix(tests): enable WebGPU rendering in headless Chromium Jul 17, 2026
@jspanchu
jspanchu requested a review from jourdain July 17, 2026 21:21
@jspanchu jspanchu changed the title fix(tests): enable WebGPU rendering in headless Chromium test: enable WebGPU rendering in headless Chromium Jul 17, 2026
@jspanchu
jspanchu merged commit 3c74076 into master Jul 18, 2026
6 checks passed
@jspanchu
jspanchu deleted the fix-webgpu-tests branch July 27, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants